/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.sub;

import java.util.List;
import ru.jSkyRoom.interfaces.major.Perk;
import ru.jSkyRoom.interfaces.stub.Skill;
import ru.jSkyRoom.interfaces.sub.PerkLink;
import skyproc.AVIF;
import skyproc.FormID;

/**
 *
 * @author Rakev
 */
public class PerkLinkBridge extends SubBridge<AVIF.PerkReference> implements PerkLink {

    public PerkLinkBridge(AVIF.PerkReference adapting) {
        super(adapting);
    }

    @Override
    public Perk getPerk() {
        FormID id = getRawObject().getPerk();
        return getFinderFactory().createPerkFinder().find(id);
    }

    @Override
    public void setPerk(Perk perk) {
        FormID id = getIdProducer().produce(perk);
        getRawObject().setPerk(id);
    }

    @Override
    public int getX() {
        return getRawObject().getX();
    }

    @Override
    public void setX(int x) {
        getRawObject().setX(x);
    }

    @Override
    public int getY() {
        return getRawObject().getY();
    }

    @Override
    public void setY(int y) {
        getRawObject().setY(y);
    }

    @Override
    public float getHorizontalPos() {
        return getRawObject().getHorizontalPos();
    }

    @Override
    public void setHorizontalPos(float horiz) {
        getRawObject().setHorizontalPos((float) horiz);
    }

    @Override
    public float getVerticalPos() {
        return getRawObject().getVerticalPos();
    }

    @Override
    public void setVerticalPos(float vert) {
        getRawObject().setVerticalPos((float) vert);
    }

    @Override
    public Skill getSkill() {
        FormID id = getRawObject().getSkill();
        return getFinderFactory().createSkillFinder().find(id);
    }

    @Override
    public void setSkill(Skill skill) {
        FormID id = getIdProducer().produce(skill);
        getRawObject().setSkill(id);
    }

    @Override
    public List<Integer> getPointers() {
        return getRawObject().getPointers();
    }

    @Override
    public void addPointer(PerkLink link) {
        if (link instanceof PerkLinkBridge) {
            AVIF.PerkReference reference = ((PerkLinkBridge) link).getRawObject();
            getRawObject().addPointer(reference);
        } else {
            throw new IllegalArgumentException("Only bridge supported.");
        }
    }

    @Override
    public int getIndex() {
        return getRawObject().getIndex();
    }

    @Override
    public void setIndex(int index) {
        getRawObject().setIndex(index);
    }
}
